const {app,BrowserWindow,Notification,ipcMain}=require('electron');

let mainWindow = null;

app.on('ready',()=>{
    mainWindow=new BrowserWindow({
        width:1200,
        height:800,
        webPreferences: {
            nodeIntegration: true,
            contextIsolation: false,
            enableRemoteModule: true,
            devTools:true,
        }
    });
    mainWindow.webContents.openDevTools({mode:'right'});

    mainWindow.loadFile("./pages/main.html").then(r => {});

    setTimeout(()=>{
        // sendMessage();
        // sendEl()
    },500)
    mainWindow.on('close',()=>{
        mainWindow=null;
    })
})


function sendMessage(){
    mainWindow.webContents.send('change-mess');
    console.log('It will work?');
}

function sendEl(){
    mainWindow.webContents.send('show-alert',123);

}

ipcMain.on('from-son',(event, arg1) =>{
    // get data from render1
    // console.log(arg1);
    // console.log(event.sender);

    console.log('got it');

    // event.reply('show-alert',123);
    // event.sender.send('show-alert',123)
    //以上两句效果一致，都是向event.sender的子进程回复信息
} )
